﻿<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="../helpproject.xsl" ?>
<topic template="Default" lasteditedby="Geert" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../helpproject.xsd">
  <title translate="true">Stylehelper</title>
  <keywords>
    <keyword translate="true">StyleHelper</keyword>
    <keyword translate="true">Styles</keyword>
    <keyword translate="true">Themes</keyword>
  </keywords>
  <body>
    <header>
      <para styleclass="Heading1"><text styleclass="Heading1" translate="true">Stylehelper</text></para>
    </header>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">The </text><link displaytype="text" defaultstyle="true" type="topiclink" href="T_Catel_Windows_StyleHelper" styleclass="Normal" translate="true">StyleHelper</link><text styleclass="Normal" translate="true"> class has a few static members that will create style forwarders. Style forwarders are styles that are defined on the application level, not on the theme level. This allows you to create forwarders with the same key as the control name, but that will forward to the </text><text styleclass="Normal" style="font-style:italic;" translate="true">DefaultxxxStyle</text><text styleclass="Normal" translate="true">. Since the new styles are defined at the application level, you will not get any circular references because the style defined in the theme cannot access the application level resources.</text></para>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">This is accomplished by simply calling </text><link displaytype="text" defaultstyle="true" type="topiclink" href="M_Catel_Windows_StyleHelper_CreateStyleForwardersForDefaultStyles" styleclass="Normal" translate="true">StyleHelper.CreateStyleForwardersForDefaultStyles()</link><text styleclass="Normal" translate="true"> in the </text><text styleclass="Normal" style="font-style:italic;" translate="true">OnStartup</text><text styleclass="Normal" translate="true"> of an application.</text></para>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">Catel currently ships with a several theme files. This example theme file is based on the “Aero&quot; theme that is included in the WPF libraries. The theme of Catel corrects the margins, since the default “Aero&quot; theme sets the margin of all controls to 0, which will result in all the user controls being stuck together, as shown in the figure below:</text></para>
    <para styleclass="Normal"><image src="themes_nostyleforwarders.png" scale="100.00%" styleclass="Image Caption"></image></para>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">We see too many developers fixing the margins on the control directly, while this can also be accomplished by using the Catel theme and the included </text><link displaytype="text" defaultstyle="true" type="topiclink" href="T_Catel_Windows_StyleHelper" styleclass="Normal" translate="true">StyleHelper</link><text styleclass="Normal" translate="true"> class. See the image below for the final result:</text></para>
    <para styleclass="Normal"><image src="themes_styleforwarders.png" scale="100.00%" styleclass="Image Caption"></image></para>
  </body>
</topic>
